import 'dart:async';
import 'package:flutter/services.dart';

class PluginManager {
  static const MethodChannel _channel = MethodChannel('plugin_ecg');

  static Future<String> pushScanActivity() async {
    String resultStr = await _channel.invokeMethod('goToNativePage', {'ecg_title': 'ecg'});
    return resultStr;
  }
  static initChannel() {
    _channel.setMethodCallHandler((call) async {
      // 同样也是根据方法名分发不同的函数
      switch(call.method) {
        case "sendData": {
          print("发送数据");
          String msg = call.arguments["ecgSmartResult"];
          print("Native 调用 Flutter 成功，参数是：$msg");
          return "成功";
        }
      }
      return null;
    });
  }
}